/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.converter;

import br.com.foxline.model.Corrector;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author roniere
 */
@FacesConverter(value = "correctorconverter")
public class CorrectorConverter implements Converter{

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        if(! value.equals("null")){
            Corrector corretor = new Corrector();
            corretor.setId((Long.valueOf(value)));
            return corretor;
        }
        return null;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        if(value != null){
            return ((Corrector) value).getId()+"";
        }
        return null;
    }
    
}
